@namespace SwashbucklerDiary.Rcl.Components
@inherits FocusDialogComponentBase

<CustomMDialog MyValue="Visible"
               MyValueChanged="InternalVisibleChanged"
               ContentClass="rounded-lg"
               MaxWidth="480"
               DisableAutoFocus
               OnAfterShowContent="FocusAsync">
    <MForm @ref="@form"
           Model="@model"
           OnValidSubmit="HandleOnOK"
           EnableI18n="true">
        <MCard>
            <MCardTitle Class="font-weight-bold">
                @(Title)
                <MSpacer></MSpacer>
                <MButton Icon="true" OnClick="HandleOnCancel">
                    <MIcon>
                        close
                    </MIcon>
                </MButton>
            </MCardTitle>
            <MCardText Class="pb-0">
                <MTextField @bind-Value="model.Password"
                            @ref="textField"
                            Dense
                            MinHeight="48"
                            Filled
                            Rounded
                            Counter="@MaxLength"
                            maxlength="@MaxLength"
                            spellcheck="false"
                            Placeholder="@(I18n.T("Please enter password"))"
                            AppendIcon="@(showPassword1 ? "visibility" : "visibility_off")"
                            Type="@(showPassword1 ? "text" : "password")"
                            OnAppendClick="() => showPassword1 = !showPassword1">
                </MTextField>
                <MTextField @bind-Value="model.PasswordConfirmation"
                            Dense
                            MinHeight="48"
                            Filled
                            Rounded
                            Counter="@MaxLength"
                            maxlength="@MaxLength"
                            spellcheck="false"
                            Placeholder="@(I18n.T("Please enter the password again"))"
                            AppendIcon="@(showPassword2 ? "visibility" : "visibility_off")"
                            Type="@(showPassword2 ? "text" : "password")"
                            OnAppendClick="() => showPassword2 = !showPassword2">
                </MTextField>
            </MCardText>
            <MCardActions Class="pt-0">
                <MSpacer></MSpacer>
                <MButton Text="true" OnClick="HandleOnCancel">
                    @(I18n.T("Cancel"))
                </MButton>
                <MButton Text="true"
                         Type="submit"
                         Color="primary">
                    @(I18n.T("Save"))
                </MButton>
            </MCardActions>
        </MCard>
    </MForm>
</CustomMDialog>